using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameOverUI : MonoBehaviour
{
    /// <summary>
    /// ui根节点
    /// </summary>
    private GameObject _uiRoot;
    
    void Start()
    {
        _uiRoot = GameObject.Find("UIRoot");
        // 隐藏
        _uiRoot.gameObject.SetActive(false);
        // 注册-玩家游戏结束回调
        PlayerController.GameOverAction += GameOverAction;
        // 注册-玩家复活
        PlayerController.ReviveAction += ReviveAction;
    }

    private void OnDestroy()
    {
        // 注销-玩家游戏结束回调
        PlayerController.GameOverAction -= GameOverAction;
        // 注册-玩家复活
        PlayerController.ReviveAction -= ReviveAction;
    }

    /// <summary>
    /// 游戏结束
    /// </summary>=
    private void GameOverAction()
    {
        _uiRoot.gameObject.SetActive(true);
    }

    /// <summary>
    /// 复活
    /// </summary>
    private void ReviveAction()
    {
        _uiRoot.gameObject.SetActive(false);
    }

}
